package com.sad.jetpack.v1.datamodel.api;

public interface IDataModelProduceFuture<RP> extends IDataModelProduceFutureObservable<RP> {

    int NOT_STARTED =0;
    int RUNNING=1;
    int EXCEPTION=2;
    int DONE=3;
    int CANCELLED=4;
    IDataModelRequest getRequest();
     <T extends Throwable> T getException();
    void cancel();
    IDataModelResponse<RP> getResponse();
    int getCurrState();
    void addObserver(boolean sticky,IDataModelProduceFutureObserver<RP> observer);
    void removeObserver(IDataModelProduceFutureObserver observer,boolean resetStateWhenNoObserver);
    void removeObserver(String id,boolean resetStateWhenNoObserver);
    void clearObservers(boolean resetState);
    void resetFutureState();
    IDataModelProduceFuture<RP> unregisterSelf();
    void registerSelf();
    IDataModelProducer<RP> newRequestToExecute(IDataModelRequest request);
    void reRequestToExecute();
    boolean hasObservers();
    Creator<RP> toCreator();

    interface Creator<RP>{
        Creator<RP> updateBindingProducer(IDataModelProducer<RP> producer);
        Creator<RP> updateRequest(IDataModelRequest request);
        IDataModelProduceFuture<RP> create();
    }
}
